package cn.com.connext.scrm.web.rest;

import cn.com.connext.scrm.domain.master.Activity;
import cn.com.connext.scrm.domain.master.AwardRecord;
import cn.com.connext.scrm.service.ActivityService;
import cn.com.connext.scrm.service.WxAPIService;
import com.codahale.metrics.annotation.Timed;
import com.connext.common.web.rest.BaseResource;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;
import java.util.concurrent.TimeoutException;

/**
 * Created by WangZhan on 2019/02/18.
 */
@RestController
@RequestMapping("/api/risky")
public class RiskyResource extends BaseResource {
    private final Logger log = LoggerFactory.getLogger(RiskyResource.class);

    @Autowired
    private WxAPIService wxAPIService;

    public RiskyResource() throws TimeoutException {
        super("risky");
    }

    @PostMapping("/msgSecCheck")
    @Timed
    @ApiOperation(value = "违规文字检测", tags = {"内容安全检测"}, notes = "违规文字检测")
    public ResponseEntity msgSecCheck(String msg){

        return entityResponse(wxAPIService.msgSafeCheck(msg));
    }


    @PostMapping(value = "/imageSecCheck", consumes = "multipart/form-data", headers = ("Content-Type=*"))
    @Timed
    @ApiOperation(value = "违规图片检测", tags = {"内容安全检测"}, notes = "违规图片检测")
    public ResponseEntity imageSecCheck(@RequestParam("media") MultipartFile file) throws  Exception{
        log.info("进入方法");
        if(file.isEmpty()){
            return entityResponse("文件为空");
        }
        return entityResponse(wxAPIService.imgaeSafeCheck(file));
    }

}
